<template>
  <div>
    <el-form :inline="true" v-model="args">
      <el-form-item label="租赁编号">
        <el-input v-model="args.id"></el-input>
      </el-form-item>
      <el-form-item label="租赁计划名称">
        <el-input v-model="args.plan_name"></el-input>
      </el-form-item>
      <el-form-item label="项目名称">
        <el-input v-model="args.projectName"></el-input>
      </el-form-item>
      <el-form-item>
        <el-select v-model="args.order">
          <el-option label="自定义排序" value=""></el-option>
          <el-option
            label="登记时间从高到低"
            value="fill_date.desc"
          ></el-option>
          <el-option label="登记时间从低到高" value="fill_date.asc"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="填报人">
        <el-input v-model="args.fill_user"></el-input>
      </el-form-item>
      <el-form-item>
        <el-select v-model="args.approve_status">
          <el-option label="选择审批状态" value=""></el-option>
          <el-option label="未提交" value="0"></el-option>
          <el-option label="审批中" value="1"></el-option>
          <el-option label="审批不通过" value="2"></el-option>
          <el-option label="审批通过" value="3"></el-option>
          <el-option label="作废" value="4"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="listLeasePlan()">查询</el-button>
      </el-form-item>
    </el-form>

    <div>
      <el-table :data="leasePlan" style="width: 100%">
        <el-table-column prop="id" label="编号" width="180">
        </el-table-column>
        <el-table-column prop="planName" label="租赁计划名称" width="180">
        </el-table-column>
        <el-table-column prop="pid" label="项目名称" :formatter="projectNameFormater"> </el-table-column>
        <el-table-column prop="fillUser" label="填报人"> </el-table-column>
        <el-table-column prop="fillDate" label="日期"> </el-table-column>
        <el-table-column prop="approveStatus" label="流程状态"> </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import leasePlan from "../../model/hyh/LeasePlan.js";
const lp = new leasePlan();
export default {
  data() {
    return {
      args: {
        id: "",
        plan_name: "",
        projectName: "",
        fill_user: "",
        order: "",
        approve_status: "",
      },
      leasePlan: [],
      projectInfo:[]
    };
  },
  methods: {
    listLeasePlan() {
      lp.listLeasePlan(this.args).then((response) => {
        this.leasePlan = response.data;
      });
    },
      //查询项目名称
    getProjectInfo(){
        lp.getProject().then((response)=>{
          this.projectInfo=response.data
      })
    },
  
    projectNameFormater(row){
     
      for(let i=0;i<this.projectInfo.length;i++){
        if(row.pid==this.projectInfo[i].id){
          return this.projectInfo[i].projectName;
        }
      }
     
    }
  },
  created() {
    this.listLeasePlan();
    this.getProjectInfo()
    console.log(this.leasePlan);
  },
};
</script>

<style>
</style>